//
//  HelloWorldLayer.m
//  MGame
//
//  Created by Ian Phillipchuk on 11-03-16.
//  Copyright Lunchpocalypse 2011. All rights reserved.
//

// Import the interfaces
#import "MenuScene.h"
#import "TestBench1.h"
#import "TestBench2.h"
#import "TestBench3.h"
#import "TestBench4.h"

// HelloWorld implementation
@implementation MenuScene

+(id) scene
{
	// 'scene' is an autorelease object.
	CCScene *scene = [CCScene node];
	
	// 'layer' is an autorelease object.
	MenuScene *layer = [MenuScene node];
	
	// add layer as a child to scene
	[scene addChild: layer];
	
	// return the scene
	return scene;
}
// set up the Menus
-(void) setUpMenus
{
	
	// Create some menu items
	CCMenuItemImage * menuItem1 = [CCMenuItemImage itemFromNormalImage:@"myfirstbutton.png"
														 selectedImage: @"myfirstbutton_selected.png"
																target:self
															  selector:@selector(doSomethingOne:)];
	
	CCMenuItemImage * menuItem2 = [CCMenuItemImage itemFromNormalImage:@"mysecondbutton.png"
														 selectedImage: @"mysecondbutton_selected.png"
																target:self
															  selector:@selector(doSomethingTwo:)];
	
	
	CCMenuItemImage * menuItem3 = [CCMenuItemImage itemFromNormalImage:@"mythirdbutton.png"
														 selectedImage: @"mythirdbutton_selected.png"
																target:self
															  selector:@selector(doSomethingThree:)]; 
	
	
	// Create a menu and add your menu items to it
	CCMenu * myMenu = [CCMenu menuWithItems:menuItem1, menuItem2, menuItem3, nil];
	
	// Arrange the menu items vertically
	[myMenu alignItemsVerticallyWithPadding:2];
	
	// add the menu to your scene
	[self addChild:myMenu];
}
// on "init" you need to initialize your instance
-(id) init
{
	// always call "super" init
	// Apple recommends to re-assign "self" with the "super" return value
	if( (self=[super init] )) {
		[self setUpMenus];
	}
	return self;
}

//
//	Dealloc Function
//
- (void) dealloc
{
	// in case you have something to dealloc, do it in this method
	// in this particular example nothing needs to be released.
	// cocos2d will automatically release all the children (Label)
	
	// don't forget to call "super dealloc"
	[super dealloc];
}

//
//	Menu Functions
// 
- (void) doSomethingOne: (CCMenuItem  *) menuItem 
{
	NSLog(@"Swapping to first testbench");
	[[CCDirector sharedDirector] replaceScene:[CCTransitionFade transitionWithDuration:1.0 scene:[TestBench1 node]]];
}
- (void) doSomethingTwo: (CCMenuItem  *) menuItem 
{
	NSLog(@"Swapping to second testbench");
	[[CCDirector sharedDirector] replaceScene:[CCTransitionFade transitionWithDuration:1.0 scene:[TestBench2 node]]];
}
- (void) doSomethingThree: (CCMenuItem  *) menuItem 
{
	NSLog(@"Swapping to third testbench");
	[[CCDirector sharedDirector] replaceScene:[CCTransitionFade transitionWithDuration:1.0 scene:[TestBench3 node]]];
}


@end